import FileApi, {FileObj} from "@/api/web/FileApi.ts";
import React from "react";
import MyArtPlayer from "@/components/MyArtPlayer";
import {ViewProcessor} from "@/components/FilePreviewProcess/processors/_index.ts";

const _main = ({fileObj}: { fileObj: FileObj }) => {
    return (
        <MyArtPlayer
            getInstance={(art) => {
                art.switchUrl(FileApi.getFileLink(fileObj.path))
            }}
        />
    )
}

export default class VideoView extends ViewProcessor {
    protected uniKey: string = "VideoView";

    getName = () => "视频"

    ViewFunctionComponent = () => <_main fileObj={this.fileObj}/>

    isViewAble = () => {
        return !!(this.fileObj && this.fileObj.contentType && this.fileObj.contentType.startsWith('video'));
    }
}
